#include "Window.h"
#include <gl\glew.h>
#include <stdio.h>
#include "SceneManager.h"

Window::Window(int width,int height,const char * title)
{
	glfwWindow = nullptr;
	this->width = width;
	this->height = height;
	this->title = title;
}


Window::~Window(void)
{
	if(sceneManager != nullptr)
		delete sceneManager;

	glfwDestroyWindow(glfwWindow);
	glfwTerminate();
}

void Window::SetBGColor(Color color)
{
	bgColor = color;
}

void Window::Init()
{
	glfwInit();
	glfwWindowHint(GL_MAJOR_VERSION,4);
	glfwWindowHint(GL_MINOR_VERSION,2);

	glfwWindow = glfwCreateWindow(width,height,title,nullptr,nullptr);
	glfwMakeContextCurrent(glfwWindow);

	glewExperimental = true;
	glewInit();

	sceneManager = new SceneManager(width,height);
}


void Window::Present()
{
	glfwSwapBuffers(glfwWindow);
	glfwPollEvents();
}


int Window::Closed()
{
	return glfwWindowShouldClose(glfwWindow);
}

SceneManager * Window::GetSceneManager()
{
	return sceneManager;
}